#define _CRT_SECURE_NO_WARNINGS


int getSum(int a, int b) {
    int num = 0;
    int ret = 0;
    for (int i = 0; i < 32; i++) {
        if (((a >> i) & 1) == 1 && ((a >> i) & 1) == ((b >> i) & 1)) {
            if (num == 1) {
                ret = ret | (1 << i);
            }
            else {
                num = 1;
            }
        }
        else if (((a >> i) & 1) == 1 && ((b >> i) & 1) == 0 ||
            ((a >> i) & 1) == 0 && ((b >> i) & 1) == 1) {
            if (num == 0) {
                ret = ret | (1 << i);
            }
        }
        else {
            if (num == 1) {
                ret = ret | (1 << i);
                num = 0;
            }
        }
    }
    return ret;
}
int main() {

    getSum(20, 30);

    return 0;
}